/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.com.menosehmais.model;

import br.com.menosehmais.framework.persistence.DomainObject;
import br.com.menosehmais.framework.persistence.IHaveCreationDateTime;
import br.com.menosehmais.framework.persistence.IHaveLastUpdate;
import br.com.menosehmais.framework.security.role.Role;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.FetchType;
import javax.persistence.MappedSuperclass;
import javax.validation.constraints.NotNull;
import org.hibernate.annotations.Type;
import org.joda.time.LocalDateTime;

/**
 *
 * @author Junior JAFJ
 */
@MappedSuperclass
public abstract class ContaDO extends DomainObject implements IHaveCreationDateTime, IHaveLastUpdate{
    //@Email
    @NotNull
    @Column(unique = true)
    private String email;
    
    @NotNull
    private String senha;

    //@Basic(fetch = FetchType.LAZY)
    //@NotNull
    private String encryptedPassword;

    //@NotNull
    @Column(unique = true)
    @Basic(fetch = FetchType.EAGER)
    private String login;
        
    @Column(updatable = false)
    @Type(type = "org.joda.time.contrib.hibernate.PersistentLocalDateTime")
    private LocalDateTime creationDateTime;

    public abstract Role role();

    public String getLogin() {
        return login;
    }

    public void setLogin(String login) {
        this.login = login;
    }

    public String getEncryptedPassword() {
        return encryptedPassword;
    }

    public void setEncryptedPassword(String encryptedPassword) {
        this.encryptedPassword = encryptedPassword;
    }
    
    @Type(type = "org.joda.time.contrib.hibernate.PersistentLocalDateTime")
    private LocalDateTime lastUpdate;

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public String getSenha() {
        return senha;
    }

    public void setSenha(String senha) {
        this.senha = senha;
    }

    @Override
    public LocalDateTime getCreationDateTime() {
        return creationDateTime;
    }

    @Override
    public void setCreationDateTime(LocalDateTime creationDateTime) {
        this.creationDateTime = creationDateTime;
    }

    @Override
    public LocalDateTime getLastUpdate() {
        return lastUpdate;
    }

    @Override
    public void setLastUpdate(LocalDateTime lastUpdate) {
        this.lastUpdate = lastUpdate;
    }
}
